﻿<RibbonWindow x:Class="UML_Creator.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Model="clr-namespace:UML_Creator.Model;assembly=UML_Creator.Model"
        xmlns:View="clr-namespace:UML_Creator.View"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        Height="512"
        Width="1024"
        MinWidth="312"
        MinHeight="250"
        Title="UML Creator"
        Icon="/UML_Creator;component/Images/Logo_48x48.png"
        DataContext="{Binding Source={StaticResource Locator}, Path=Main}">

    <Window.Resources>
        <DataTemplate DataType="{x:Type Model:ClassDiagram}">
            <Canvas>
                <View:ClassDiagram />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:ActivityDiagram}">
            <Canvas>
                <View:ActivityDiagram />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:InterfaceDiagram}">
            <Canvas>
                <View:InterfaceDiagram />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:FullLineEdge}">
            <Canvas>
                <View:FullLineEdgeUserControl />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:DiamondEdge}">
            <Canvas>
                <View:DiamondEdgeUserControl />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:FilledDiamondEdge}">
            <Canvas>
                <View:FilledDiamondEdgeUserControl />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:ArrowEdge}">
            <Canvas>
                <View:ArrowEdgeUserControl />
            </Canvas>
        </DataTemplate>
        <DataTemplate DataType="{x:Type Model:DashedArrowEdge}">
            <Canvas>
                <View:DashedArrowEdgeUserControl />
            </Canvas>
        </DataTemplate>
    </Window.Resources>
    <DockPanel x:Name="LayoutRoot">
        <StatusBar DockPanel.Dock="Bottom" Height="30" HorizontalAlignment="Right" Background="White" BorderThickness="1,1,0,0" BorderBrush="Black" Panel.ZIndex="99">
            <Label Content="Zoom" HorizontalAlignment="Right" ></Label>
            <Slider Maximum="5" Width="200" Value="{Binding Zoom}" ToolTip="Zoom" HorizontalAlignment="Right" TickPlacement="BottomRight" Minimum="0.1" >
            </Slider>
        </StatusBar>
        <View:MvvmView3 DockPanel.Dock="Top" Panel.ZIndex="98"/>
        <Canvas Width="auto" Height="auto" Background="Transparent">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDown">
                    <cmd:EventToCommand Command="{Binding MouseDownCanvasCommand}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="MouseMove">
                    <cmd:EventToCommand Command="{Binding DataContext.MouseMoveCanvasCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="MouseUp">
                    <cmd:EventToCommand Command="{Binding DataContext.MouseUpCanvasCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>

            <ItemsControl ItemsSource="{Binding Edges}" Panel.ZIndex="0">
                <ItemsControl.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="{Binding Zoom}" ScaleY="{Binding Zoom}" CenterX="500" CenterY="500"/>
                        <SkewTransform/>
                        <RotateTransform />
                        <TranslateTransform X="{Binding TranslateX}" Y="{Binding TranslateY}"/>
                    </TransformGroup>
                </ItemsControl.RenderTransform>
            </ItemsControl>
            <ItemsControl ItemsSource="{Binding Nodes}" Panel.ZIndex="1">
                <ItemsControl.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform CenterX="500" ScaleX="{Binding Zoom}" ScaleY="{Binding Zoom}" CenterY="500"/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform X="{Binding TranslateX}" Y="{Binding TranslateY}"/>
                    </TransformGroup>
                </ItemsControl.RenderTransform>
            </ItemsControl>
        </Canvas>
    </DockPanel>

</RibbonWindow>
